package net.bolue.sysmng.sysres.model;

import java.util.Map;

import net.bolue.console.model.BusiBase;
import net.bolue.sysmng.db.DbOpUtil;
import net.bolue.sysmng.exception.BolueException;
import net.bolue.sysmng.util.EncryptUtil;

public class DBResManager extends BusiBase{

	public int insertDBRes(Map<String,Object> insertMap) throws BolueException{
		String passwd = (String)insertMap.get("PASSWD");
		if(passwd!=null){
			try {
				String s = EncryptUtil.encrypt(passwd);
				insertMap.put("PASSWD", s);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		String dbResId = "sysmng";
		String table = "st_dbres";
		DbOpUtil dbOpUtil = new DbOpUtil(dbResId);
		return dbOpUtil.insert(table, insertMap);
	}
	
	public int updDBRes(Map<String,Object> updateMap,Map<String,Object> whereMap) throws BolueException{
		String passwd = (String)updateMap.get("PASSWD");
		if(passwd!=null){
			try {
				String s = EncryptUtil.encrypt(passwd);
				updateMap.put("PASSWD", s);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		String dbResId = "sysmng";
		String table = "st_dbres";
		DbOpUtil dbOpUtil = new DbOpUtil(dbResId);
		return dbOpUtil.update(table, updateMap,whereMap);
	}
}
